﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<TogheterWeBuyIt.Models.Promocao>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	Details
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

<table align="left" width="70%">
    <tr>
        <td style="width: 136px">Descrição: </td>
        <td><%= Html.Encode(Model.Descricao) %></td>
    </tr>
    <tr>
        <td style="width: 136px">Período de validade: </td>
        <td>
        <% if (Model.DataValidadeInicio.HasValue)
           { %>
            de <%= Html.Encode(Model.DataValidadeInicio.Value.ToString("dd/MM/yyyy"))%> 
        <% } %>
        <% if (Model.DataValidadeFim.HasValue)
           { %>
            até <%= Html.Encode(Model.DataValidadeFim.Value.ToString("dd/MM/yyyy"))%>
        <%} %>
        </td>
    </tr>
    <tr>
        <td style="width: 136px">Criador: </td>
        <td><%= Html.ActionLink(Model.Usuario.Login, "Details", "Usuario", new { id = Model.IdUsuario }, null)%></td>
    </tr>
    <tr>
        <td style="width: 136px">Mínimo/Máximo de participantes: </td>
        <td>
        <% if (Model.ClientesMin.HasValue)
           { %>
        <%= Html.Encode(Model.ClientesMin.Value)%>
        <% }
           else
           { %>
            - 
         <% } %>
         /
         <% if (Model.ClientesMax.HasValue)
           { %>
        <%= Html.Encode(Model.ClientesMax.Value)%>
        <% }
           else
           { %>
            - 
         <% } %>
         </td>
    </tr>
     <tr>
        <td style="width: 136px">Link: </td>
        <td><%= Html.Encode(Model.Link) %></td>
    </tr>
    <tr>
        <td colspan="2" align="center"><% if (Session["LoggedUserId"] == null)
               { %>
               <%= Html.ActionLink("LogIn", "LogIn", "Usuario",null, null) %>
            <% }
               else if (Model.ParticipaPromocaos != null && !Model.ParticipaPromocaos.Any(p => p.IdUsuario == (int)Session["LoggedUserId"]))
               { %>
                    <%= Html.ActionLink("Participar", "Participate", new { id = Model.Id })%>
            <% }
               else
               { %>
                    <%= "Já estou participando"%>
            <% } %></td>
    </tr>
</table>                                                 
<asp:Panel ID="Panel2" ScrollBars="Auto" runat="server" style="max-height:200px; width:30%;" ><% Html.RenderPartial("Controls/UPromoParticipantes", Model.ParticipaPromocaos); %></asp:Panel>
<p></p>
<p><asp:Panel ID="Panel1" ScrollBars="Auto" runat="server" style="max-height:200px; width:100%; margin-top:20px;" ><% Html.RenderPartial("Controls/UPromoProducts", Model.PromocaoProdutos); %></asp:Panel></p>

                                                                                                            
 <asp:Panel ID="Panel3" ScrollBars="Auto" width="100%" runat="server" style="max-height:400px; margin-top:20px;" >
                   <% Html.RenderPartial("Controls/UComentariosPromocao", Model); %>
                   </asp:Panel>
                   <br />
                   <% if (Session["LoggedUserId"] != null && (int)Session["LoggedUserId"] > 0)
                      {
                          Html.BeginForm("InserirComentario", "Promocao", FormMethod.Post);
                   %>
                   <table width="100%" align="center">
                    <tr>
                        <td colspan="2" align="center">
                        Fazer Comentário
                        </td>
                    </tr>
                       <tr>
                           <td>
                                <textarea rows="5" id="Texto" name="Texto" style="width:90%;"></textarea>
                                <%= Html.Hidden("IdPromocao", Model.Id) %>
                           </td>
                           <td>
                                <input type="submit" id="Submit"  value="Enviar" />
                           </td>
                       </tr>
                   </table>
                   <%
                       Html.EndForm();
                      } %>
</asp:Content>

